// 我方战斗机
import { h, defineComponent, toRefs } from "@vue/runtime-core";
import plantImg from "../assets/plane.png";

export default defineComponent({
      props: ["x", "y",  "width", "height"],
      setup(props, ctx) {
            const { x, y, width, height } = toRefs(props);

            window.addEventListener("keydown", (e) => {  
                  if(e.code === "Space"){ 
                        ctx.emit("attack", {x: x.value + 100, y: y.value })
                  }
            })

            return {x, y, width, height}
      },

      render(ctx) {
            return h("Container", [
                  h("Sprite", {
                        texture: plantImg,
                        x: ctx.x,
                        y: ctx.y,
                        width: ctx.width,
                        height: ctx.height
                  }),
            ]);
      },
});
